package com.xrz.sxm.aj.view;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

public class TouchRelativeLayout extends RelativeLayout {

	public static final String ACTION_MOVE_ = "xrz.sxm.ACTION_MOVE_";
	public static final String ACTION_UP_ = "xrz.sxm.ACTION_UP_";

	private Context m_ctx;

	public TouchRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub = con
		this.m_ctx = context;
	}

	public TouchRelativeLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		this.m_ctx = context;
	}

	public TouchRelativeLayout(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		this.m_ctx = context;
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			return true;
		case MotionEvent.ACTION_MOVE:
			m_ctx.sendBroadcast(new Intent(ACTION_MOVE_).putExtra("x",
					event.getX()).putExtra("y", event.getY()));
			return false;
		case MotionEvent.ACTION_CANCEL:
		case MotionEvent.ACTION_UP:
			m_ctx.sendBroadcast(new Intent(ACTION_UP_));
			return false;
		}
		return true;
	}

}
